package com.yunwushanhe.controller;

import com.yunwushanhe.annotation.SystemLog;
import com.yunwushanhe.bean.req.*;
import com.yunwushanhe.bean.ret.ResponseResult;
import com.yunwushanhe.bean.vo.LinkPageListVO;
import com.yunwushanhe.bean.vo.LinkUpdateVO;
import com.yunwushanhe.bean.vo.PageVO;
import com.yunwushanhe.service.LinkService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

/**
 * 友链(Link)表控制层
 *
 * @author 抬头看看天
 * @since 2023-08-27 18:44:38
 */
@RestController
@RequestMapping("/content/link")
public class LinkController {

    @Resource
    private LinkService linkService;

    @GetMapping("/list")
    @SystemLog(businessName = "分页查询友联列表的接口能根据\n" +
                                "友联名称进行模糊查询；\n" +
                                "能根据状态进行查询。")
    public ResponseResult<PageVO<List<LinkPageListVO>>> getLinkPageList(LinkPageListReq linkPageListReq){
        return linkService.getLinkPageList(linkPageListReq);
    }

    @PostMapping
    @SystemLog(businessName = "新增友联的接口")
    public ResponseResult<Object> addLink(@RequestBody LinkAddReq linkAddReq){
        return linkService.addLink(linkAddReq);
    }

    @GetMapping("/{id}")
    @SystemLog(businessName = "根据id查询所指定类别信息的接口，用于友联信息修改回显")
    public ResponseResult<LinkUpdateVO> getLinkUpdateById(@PathVariable("id") Long id){
        return linkService.getLinkUpdateById(id);
    }

    @PutMapping
    @SystemLog(businessName = "更新友联的接口")
    public ResponseResult<Object> updateLinkById(@RequestBody LinkUpdateReq linkUpdateReq){
        return linkService.updateLinkById(linkUpdateReq);
    }

    @DeleteMapping("/{id}")
    @SystemLog(businessName = "删除友联的接口")
    public ResponseResult<Object> deleteLinkById(@PathVariable("id") String id){
        return linkService.deleteLinkById(id);
    }

    @PutMapping("/changeLinkStatus")
    @SystemLog(businessName = "友联审核评判的接口")
    public ResponseResult<Object> changeLinkStatus(@RequestBody LinkStatusUpdateReq linkStatusUpdateReq){
        return linkService.changeLinkStatus(linkStatusUpdateReq);
    }

}

